<template>
  <div class="quoteCalculateIndex">
    <div class="quoteCalculateIndex_head_box">
      <div class="quoteCalculateIndex_head_return" @click="returnHistiy">
        <img src="@/pages/mobile/assets/img/Back@3x.png" alt />
        <span>任务中心</span>
      </div>
      <p>报价测算</p>
      <div class="quoteCalculateIndex_head_img">
        <img
          src="@/pages/mobile/assets/img/Search@3x.png"
          @click="searchInfo"
          alt
        />
      </div>
    </div>
    <scroll
      :loadDatas="quoteCalculateData"
      :pullUpLoad="pullUpLoad"
      :pulldown="pulldown"
      @pullingDown="loadDownData"
      @pullingUp="loadUpData"
      class="quoteCalculateIndex_scroll"
    >
      <div class="quoteCalculateIndex_content">
        <div
          class="quoteCalculateIndex_content_item"
          v-for="item in quoteCalculateData"
          @click="quoteCalculateItemInfo(item.quoteCalculatorId)"
        >
          <div class="quoteCalculateIndex_content_item_data">
            <p>{{ item.quoteName }}</p>
            <span>{{ item.financingAmount.toLocaleString() }}</span>
          </div>
          <div class="quoteCalculateIndex_content_item_details">
            <i>查看详情</i>
            <x-icon
              class="details_img"
              type="ios-arrow-forward"
              size="23"
            ></x-icon>
          </div>
        </div>
      </div>
    </scroll>
    <div class="customerManagement_fonter" @click="quoteCalculateIndexAdd">
      <x-icon type="ios-plus-empty" size="56"></x-icon>
    </div>
  </div>
</template>

<script>
import Scroll from "@/pages/mobile/assets/js/JoysScroll/JoysScroll";
export default {
  name: "quoteCalculateIndex",
  components: {
    Scroll
  },
  data () {
    return {
      quoteCalculateData: [],
      pullUpLoad: true,
      pulldown: true,
      pageNum: 1,

    }
  },
  methods: {
    loadDownData () {
      setTimeout(() => {
        this.quoteCalculateQuery(1);
        this.quoteCalculateData = [];
      }, 1000);
    },
    loadUpData () {
      setTimeout(() => {
        this.pageNum++;
        this.quoteCalculateQuery(this.pageNum);
      }, 1000);
    },
    quoteCalculateQuery (pageNum) {
      this.$axios({
        method: "post",
        url: "/joys-rest/joys-calculate/calculator/list/page",
        headers: {
          "AUTH-TOKEN": localStorage.getItem("AUTH-TOKEN"),
          "Content-Type": "application/json;charset=UTF-8"
        },
        params: {
          pageIndex: pageNum,
          pageSize: 10
        },
        data: ""
      })
        .then(res => {
          // this.quoteCalculateData = res.data.rows
          this.quoteCalculateData = this.quoteCalculateData.concat(
            res.data.rows
          );
        })
        .catch(error => {
          console.log("error", "登录错误");
        });
    },
    searchInfo () {
      this.$router.push({
        path: '/calculator/quoteCalculateSearch',
      })
    },
    // 返回
    returnHistiy () {
      this.$router.goBack();
    },
    // 添加新报价
    quoteCalculateIndexAdd () {
      this.$router.push({
        path: '/calculator/quoteCalculateAdd',
      })
    },
    // 查看详情
    quoteCalculateItemInfo (id) {
      this.$router.push({
        path: '/calculator/quoteCalculateResult',
        query: {
          id: id
        }
      })
    }
  },
  created () {
    this.quoteCalculateQuery(1)
  },

}
</script>

<style lang="less" scoped>
.quoteCalculateIndex {
  z-index: 300;
  width: 100%;
  height: 100%;
  background-color: #fbf9fe;
  .quoteCalculateIndex_head_box {
    width: 100%;
    height: 0.44rem;
    line-height: 0.44rem;
    position: fixed;
    z-index: 201;
    background: #ffffff;
    box-shadow: inset 0 -1px 0 0 rgba(207, 207, 207, 0.2);
    .quoteCalculateIndex_head_return {
      // width: 100%;
      position: fixed;
      top: 0px;
      float: left;
      margin-top: -0.04rem;
      float: left;
      img {
        // width: 0.15rem;
        height: 0.205rem;
        padding-left: 0.085rem;
        padding-top: 0.02rem;
      }
      span {
        font-family: Regular;
        font-size: 0.16rem;
        color: #3e3e3e;
        letter-spacing: -0.41px;
        line-height: 0.22rem;
      }
    }
    p {
      font-family: PingFangSC-Semibold;
      font-size: 0.16rem;
      color: #3e3e3e;
      letter-spacing: -0.41px;
      height: 0.44rem;
      font-weight: 700;
      line-height: 0.44rem;
      text-align: center;
    }
    .quoteCalculateIndex_head_img {
      margin-top: -0.46rem;
      float: right;
      margin-right: 0.2rem;
      img {
        margin-left: -0.05rem;
        height: 0.22rem;
      }
    }
  }
  .quoteCalculateIndex_scroll {
    overflow: hidden;
    top: 0.44rem;
    .quoteCalculateIndex_content {
      margin: 0 0.16rem;
      padding-top: 0.1rem;
      padding-bottom: 0.1rem;
      .quoteCalculateIndex_content_item {
        margin-top: 0.1rem;
        background: #ffffff;
        box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.06);
        border-radius: 5px;
        // height: 0.91rem;
        padding: 0.12rem 0.12rem 0.1rem 0.12rem;
        .quoteCalculateIndex_content_item_data {
          height: 0.66rem;
          border-bottom: 1px solid #eeeeee;
          p {
            font-family: PingFangSC-Regular;
            font-size: 0.14rem;
            color: #443a38;
            letter-spacing: 0;
            height: 0.2rem;
            line-height: 0.2rem;
          }
          span {
            font-family: PingFangSC-Semibold;
            font-size: 0.24rem;
            color: #e5a83f;
            letter-spacing: 0.67px;
            height: 0.4rem;
            line-height: 0.4rem;
          }
        }
        .quoteCalculateIndex_content_item_details {
          padding-top: 0.1rem;
          height: 0.22rem;
          display: flex;
          align-items: center;
          i {
            font-family: PingFangSC-Regular;
            font-size: 0.12rem;
            color: #9c9795;
            letter-spacing: -0.29px;
            line-height: 0.14rem;
          }
          .vux-x-icon {
            fill: #d1d1d6;
          }
          .details_img {
            position: absolute;
            right: 0.24rem;
          }
        }
      }
      .quoteCalculateIndex_content_item:nth-child(2n) {
        .quoteCalculateIndex_content_item_data {
          span {
            color: rgba(23, 42, 136, 0.8);
          }
        }
      }
      .quoteCalculateIndex_content_item:first-child {
        margin-top: 0rem;
      }
    }
  }
  .customerManagement_fonter {
    position: absolute;
    width: 0.56rem;
    bottom: 0.14rem;
    right: 0.24rem;
    height: 0.56rem;
    overflow: hidden;
    border-radius: 50%;
    background: #be9457;
    display: flex;
    justify-content: center;
    align-items: center;
    .vux-x-icon {
      fill: #fff;
    }
  }
}
</style>
